//
//  SelectInfoV.swift
//  Employee
//
//  Created by swordjoy on 2017/3/27.
//  Copyright © 2017年 remotevillage. All rights reserved.
//

import UIKit

class SelectInfoV: UIView {
  
  var detail: String = "" {
    
    didSet { self.detailLabel.text = detail }
    
  }
  
  fileprivate var contentV: UIView!
  fileprivate var titleLabel: UILabel!
  fileprivate var detailLabel: UILabel!
  fileprivate var detailImageV: UIImageView!
  
  init(frame: CGRect, title: String, detail: String = "选择") {
    super.init(frame: frame)
    backgroundColor = UIColor.clear
    create()
    
    titleLabel.text = title
    detailLabel.text = detail
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
}

// MARK: - fileprivate

extension SelectInfoV {
  fileprivate func create() {
    contentV = UIView()
    addSubview(contentV)
    contentV.snp.makeConstraints { (make) in
      make.left.equalTo(10)
      make.right.equalTo(-10)
      make.top.bottom.equalToSuperview()

    }
    contentV.backgroundColor = UIColor.white
    contentV.layer.cornerRadius = 4
    contentV.clipsToBounds = true
    
    titleLabel = UILabel()
    contentV.addSubview(titleLabel)
    titleLabel.font = GlobalConfig.system15Font
    titleLabel.textColor = GlobalConfig.TextDeepColor
    titleLabel.snp.makeConstraints { (make) in
      make.left.equalTo(15)
      make.centerY.equalToSuperview()
    }
    
    detailImageV = UIImageView()
    contentV.addSubview(detailImageV)
    detailImageV.image = UIImage(named: "neworder-show-more-icon")
    detailImageV.snp.makeConstraints { (make) in
      make.right.equalTo(-15)
      make.centerY.equalToSuperview()
      make.height.equalTo(14)
      make.width.equalTo(7)
    }
    
    detailLabel = UILabel()
    contentV.addSubview(detailLabel)
    detailLabel.font = GlobalConfig.system15Font
    detailLabel.textColor = GlobalConfig.TextLightColor
    detailLabel.snp.makeConstraints { (make) in
      make.centerY.equalToSuperview()
      make.right.equalTo(detailImageV.snp.left).offset(-10)
    }
  }
}
